Repository navigation
gh-144650: support Vectorcall for _decimal.Decimal's - #158207
Conversation
325c126 to
a0723f1
Compare
|
#157968 may help with the build failures (changes how the assert works which should make it better across module boundaries) |
|
Thanks. The Decimal is only possible candidate being a heap type in the stdlib. That was worked before in skirpichev#18 |
|
👍 hopefully will get more of these landed soon :). |
Convert the static types to heap types. Move empty init vectorcall to share with existing no-arg __init__ case. Add support for no-argument vectorcall so the no-arg __init__ cases actually work (rather than adding an arg). Produce the same error string as the PyArg helpers do. The vectorcall types no longer have a C address for the generated `Py_Is` so instead compare the slot function instead. This drops the requirement that a class using vectorcall declare a type object. Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com> (cherry-picked from python#157968)
# Conflicts: # Modules/clinic/_testclinic.c.h
|
I think it still worth it, assuming micro-benchmarks. It's for free, anyway. But it's on top of #157968. If you are ok, I'll reopen this one that pr (or some its alternative) will be merged. |
# Conflicts: # Tools/clinic/libclinic/parse_args.py
vstinner
left a comment
There was a problem hiding this comment.
Benchmark results were posted 1 month ago, but the PR changed in the meanwhile. Would it be possible to re-run benchmarks on the latest PR version?
|
See also #73487 which converted many Decimal methods to vectorcall using Argument Clinic. |
In fact, you can see that benchmarks already updated. Not so much, as before. #156034 shows better numbers. Now included telco benchmark.
This is something that was suggested in #160115. You can compare my previous benchmark run. IMO, the difference looks more or less as a noise: Not sure if this worth reversion. That function used only once, anyway. |
|
I don't mind the inline keyword, it's a compiler hint that is largely ignored (which is why |
# Conflicts: # Modules/_decimal/clinic/_decimal.c.h
|
Sorry, @cmaloney, it seems that your suggestion is not clear for me. |
|
I have no preference on inline keyword or not. In this case i did some assembly looking and without the keyword it does get inlined to the _new_impl. |
#156034 (comment) was posted in August. Python changed since August, so I prefer to not rely on old benchmark numbers. It's unclear to me if #160115 (comment) include the "static inline" change or not. I would be easier for me if you can post benchmark results in this PR rather than pointing to other issues/PRs. Can you please re-run benchmarks on the latest PR version, since you just modified it? |
Ok, done. (Same setup: default configure options, gcc 14.2.) |
|
decimal_pi, decimal_factorial and telco benchmark results are a little bit disappointing. (Basically, there is no impact on performance, just a minor "1.01x faster" which could also just be noise in the results).
1.10x faster on a micro-benchmark is borderline interesting, but I think that adding I tested a sub-type: since import _decimal
class MyDecimal(_decimal.Decimal):
pass
x = MyDecimal(123) |
This shows almost no effect on "official" pyperformance benchmarks (see python/pyperformance#473):
But on micro-benchmarks it show some speedup:
(Default ./configure options, gcc 14.2)
Details